package com.cmfi.service.impl.userRoleAuthImpl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cmfi.SpringbootApplication;
import com.cmfi.dao.userRoleAuthDao.MenuAuthDao;
import com.cmfi.domain.userRoleAuthEntity.MenuAuth;
import com.cmfi.service.inter.userRoleAuthInter.MenuAuthService;

@Service
public class MenuAuthServiceImpl implements MenuAuthService {
	@Autowired
	private MenuAuthDao menuAuthDao;
	
	static Logger logger = LoggerFactory.getLogger(SpringbootApplication.class);

	@Override
	public boolean saveMenuAuth(MenuAuth permission) throws Exception {
	MenuAuth permissionInDao = menuAuthDao.getPermissionByName(permission.getMenuName());
		if (permissionInDao != null) {
			throw new Exception("指定的模块权限已存在");
		}
		int result = menuAuthDao.savePermission(permission);
		return result > 0;
	}

	@Override
	public MenuAuth getMenuAuth(Long roleId) throws Exception {
		// TODO Auto-generated method stub
		return menuAuthDao.getMenuAuthById(roleId);
	}
}
